const {
    merge
} = require("webpack-merge");
const tsImportPluginFactory = require("ts-import-plugin");

module.exports = {
    publicPath: './',
    outputDir: 'dist',
    productionSourceMap: false,
    lintOnSave: false, //关闭 eslint
    devServer: {
        proxy: {
            '/api': {
                target: 'http://abcd.com', //目标地址
                changeOrigin: true, 
                pathRewrite: {  //这里重写路径
                    '^/api': '/'
                } 
            }
        }
    },
    parallel: false,
    chainWebpack: config => {
        // vant 按需引入
        config.module
            .rule("ts")
            .use("ts-loader")
            .tap(options => {
                options = merge(options, {
                    transpileOnly: true,
                    getCustomTransformers: () => ({
                        before: [
                            tsImportPluginFactory({
                                libraryName: "vant",
                                libraryDirectory: "es",
                                style: true
                            })
                        ]
                    }),
                    compilerOptions: {
                        module: "es2015"
                    }
                });
                return options;
            });
    }
}